package com.test;

import java.util.ArrayList;
import java.util.List;

/*
 * lmc 20210304
 */
public class App {

	public String[][] arr = new String[][] { {}, {}, { "A", "B", "C" }, { "D", "E", "F" }, { "G", "H", "I" },
			{ "J", "K", "L" }, { "M", "N", "O" }, { "P", "Q", "R", "S" }, { "T", "U", "V" }, { "W", "X", "Y", "Z" } };

	public String exec(Integer[] ids) {
		List<String> list = new ArrayList<>();
		for (Integer id : ids) {
			if (id > 1 && id < 10) {
				list.addAll(add(id));
			} else if (id > 9 && id < 100) {
				String str = id.toString();
				int id1 = Integer.parseInt(str.substring(0, 1));
				if (id1 != 0 && id1 != 1) {
					list.addAll(add(id1));
				}

				int id2 = Integer.parseInt(str.substring(1, 2));
				if (id2 != 0 && id2 != 1) {
					list.addAll(add(id2));
				}
			}
		}
		List<String> result = new ArrayList<>();
		get(list, result, 0, new char[list.size()]);

		StringBuffer sb = new StringBuffer();
		for (String str : result) {
			sb.append(str.toLowerCase() + " ");
		}
		return sb.toString();
	}

	public List<String> add(int id) {
		List<String> list = new ArrayList<>();
		String value = "";
		for (String str : arr[id]) {
			value += str;
		}
		list.add(value);
		return list;
	}

	public void get(List<String> list, List<String> result, int len, char[] arr) {
		if (len == list.size()) {
			result.add(new String(arr));
			return;
		}
		for (char c : list.get(len).toCharArray()) {
			arr[len] = c;
			get(list, result, len + 1, arr);
		}
	}

	public static void main(String[] args) {
		App app = new App();
		String result1 = app.exec(new Integer[] { 2, 3 });
		String result2 = app.exec(new Integer[] { 9 });
		String result3 = app.exec(new Integer[] { 99 });
		System.out.println(result1);
		System.out.println(result2);
		System.out.println(result3);
		
	}

}